package com.ash.mpi;

import JavaAPI.HttpsPostRequest;
import JavaAPI.MpiCardLookup;
import JavaAPI.Receipt;
import com.ash.service.TransactionService;

/**
 * 用于确定特定卡号是否参与 3-D Secure 认证的请求
 * <p>
 * 请求用于验证卡片是否适用于 3DS 2.2，并返回 3DS 方法 URL，该 URL 用于设备指纹识别。这个请求是可选的，但它可能会增加无摩擦流程的机会。
 * <p>
 * 通过进行设备指纹识别，可能会增加交易流程的顺畅度，使得更多的交易能够在不需要额外验证的情况下顺利完成，从而间接提高了交易的成功率
 */
public class TestMpiWithCardLookup {


    public static void main(String[] args) {
        TransactionService transactionService = TransactionService.getInstance();
        HttpsPostRequest mpgReq = transactionService.getHttpsPostRequest();

        MpiCardLookup mpiCardLookup = new MpiCardLookup();

        mpiCardLookup.setOrderId("124");
        // 这个卡号测试指定官方指定的卡号 https://developer.moneris.com/More/Testing/Testing%203D%20Solutions
        mpiCardLookup.setPan("347668693641199");

        // 根据Hosted Tokenization 方式获取 或者通过vault服务获取
        mpiCardLookup.setDataKey("vePp1yG29QVSDyBEtYprRKeW9");
        mpiCardLookup.setNotificationUrl("https://yoururl.com");

        mpgReq.setTransaction(mpiCardLookup);

        mpgReq.send();

        Receipt receipt = mpgReq.getReceipt();


        System.out.println("ResponseCode = " + receipt.getResponseCode());
        System.out.println("threeDSecureServerTransactionId = " + receipt.getMpiThreeDSServerTransId());

        System.out.println("ReceiptId = " + receipt.getReceiptId());
        System.out.println("ThreeDSVersion = " + receipt.getThreeDSVersion());
        System.out.println("ThreeDSMethodURL = " + receipt.getMpiThreeDSMethodURL());
        System.out.println("threeDSecureMethodData = " + receipt.getMpiThreeDSMethodData());


    }
}
